﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
using Xms.Abp.Data;
using Xms.Abp.Domain;

namespace BackgroundJobManagement;

[Table("BackgroundSchedule")]
[Index(nameof(Name))]
[Index(nameof(DisplayName))]
[Index(nameof(NextExecuteTime))]
[Index(nameof(ModificationTime))]
public class BackgroundScheduleEntity : FullAuditedAggregateRoot<Guid>, IHasName<Guid>, IHasDisplayName<Guid>, IHasRemark, IHasEnabled
{
    [Required]
    [MaxLength(128)]
    public virtual string Name { get; set; }
    [Required]
    [MaxLength(128)]
    public virtual string DisplayName { get; set; }
    [Required]
    [MaxLength(128)]
    public virtual string Cron { get; set; }
    public virtual MultiTenancySides MultiTenancySides { get; set; }
    public virtual int ExecuteCount { get; set; }
    public virtual DateTime NextExecuteTime { get; set; }
    public virtual DateTime? LastExecuteTime { get; set; }
    public virtual DateTime? ModificationTime { get; set; }
    public virtual bool IsEnabled { get; set; }
    public string Remark { get; set; }

    public BackgroundScheduleEntity(Guid id)
    {
        Id = id;
    }
}
